tic

maxnbr = 4.0;
maxdim = 1.0;

theta=0:0.001:2*pi;
r = 2;
x=4;
y=4;
myimg=zeros(8,8);
myimg=myimg+1;
oldrow=0;
oldcol=0;
for i=1:length(theta)
    row=floor(y+r*sin(theta(i)));
    col=floor(x+r*cos(theta(i)));
    if((row ~= oldrow) || (col~=oldcol))
        myimg(row,col) = 0;
    end
end

img = reshape(myimg, 1, 8*8);
bwn = randimg(myimg, 0.1);
disp('Finding neighbors ...');
pause(1);
nbrmat = findnbrs(bwn, maxnbr);
disp('Neighbors construction done');
pause(1);

nbrmattmp = nbrmat-1;
nbrmattmp(nbrmattmp ~= -1)=nbrmattmp(nbrmattmp~=-1)+1;
nbrnumsmat = nbrmat - nbrmattmp;
nbrnums = maxnbr-sum(nbrnumsmat,1);
nbrmat = sort((nbrmat-1),1,'descend');
ys = [0 1];

labelmat = treebp_matlab(double(prod(size(img))),maxnbr,maxdim, ...
    double(ys), double(nbrnums), double(nbrmat),img,10.0);

toc